<!DOCTYPE html>
<html lang="cn">
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="stylesheet" type="text/css" th:href="@{/static/layui/css/layui.css}" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/organization/thesame.css}" />
		<link rel="stylesheet" th:href="@{/static/css/footer.css}" media="all">
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/wardRound/rightCon.css}" media="all" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/organization/healthPopCss.css}" media="all" />
	</head>

	<body class="layui-layout-body">
	<input id="userNo" type="hidden" name="userNo" th:value="${userNo}"/>
	<input id="batchNo" type="hidden" name="batchNo" th:value="${batchNo}"/>
		<div class="layui-body">
			<div class="add-title pad25px"><!--<span class="mr10px"><img src="../static/img/return_icon.png"></span>--><span>新建档案</span></div>
				<div class="new-add-box new-add-box-width bgWhite box-shadows border-radius4">
					<div class="add-box-scroll">
						<div class="border-bot5px border-radius4 pad25px">
							<dl class="per-look-dl">
								<dt>
									<img th:if="${userInfo['headExist']}==1" th:src="${userInfo['headUrl']}" class="block">
									<img th:if="${userInfo['headExist']}==0" th:src="@{/static/img/defaultHead.jpg}" class="block">
								</dt>
								<dd>
									<div class="overflow">
										<p class="left">
											<span th:text="${userInfo['userName']}"></span>
											<span class="border-bggray" th:text="${userInfo['bedInfo']}"></span>
										</p>
										<p class="right">
											<span class="border-bgred" th:if="${userInfo['cognitionStatus']}==1">认知问题</span>
											<span th:onclick="nursingLevelPicLayerOpen([[${userInfo.nursingImg}]])" class="border-bgred cursor" >
												<em th:text="${userInfo['nursingDegree']}"></em>
												<em class="look-em border-bgred textCenter">?</em>
											</span>
											<span class="border-bgred" th:text="${userInfo['assessmentDegree']}"></span>
										</p>
									</div>
									<div>
										<span th:text="${userInfo['userSex']}"></span>
										<span th:text="${userInfo['userAge']}+'岁'"></span>
										<span th:text="${userInfo['eduction']}"></span>
										<span th:text="${userInfo['securityType']}"></span>
										<span th:text="${userInfo['userAddress']}"></span>
									</div>
									<div>
										<span class="border-bggreen" th:text="'合同截止：'+${userInfo['contractEndDate']}"></span>
										<span class="border-bggreen" th:text="'下次护理评估时间：'+${userInfo['nursingDate']}"></span>
										<span class="border-bggreen" th:text="'评估有效期：'+${userInfo['assessmentDate']}"></span>
									</div>
								</dd>
							</dl>
						</div>
						<div class="mb25px pad25px">
							<ul class="inform-title mb25px">
								<li class="current" style="cursor: default">健康档案</li>
								<li class="current" style="cursor: default">体格检查</li>
								<li class="current" style="cursor: default">实验室检查</li>
								<li style="cursor: default">初步诊断</li>
								<li style="cursor: default">诊疗计划</li>
							</ul>
							<article class="mb25px" id="dataArticle">
								<div id="addSituation" class="green border-radius4 textCenter lh40px mt30px" style="width:800px;border: 1px dashed #ddd;"><img src="../static/elderlyInfo/img/icon_xuqian.png" style="vertical-align: -2px;" class="mr10px">添加</div>
							</article>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="layui-footer layui-footer-one">
			<div class="btn-con textCenter">
				<span class="btn-three cursor" id="prevButton">上一步</span>
				<span class="btn-two cursor" id="nextButton">下一步</span>
			</div>
		</div>
		<div id="pop-nursingLevelPicLayerOpen" style="display: none;">
			<div class="pop-up">
				<!-- 查看护理等级 -->
				<div>
					<div class="pop-title relative overflow mb15px">
						<span class="ml15px">护理等级</span>
						<p class="right"><img src="../static/elderlyInfo/img/close_icon.png" class="block pop-close"><p>
					</div>
					<div class="mt10px">
						<p><img id="nursingPic" th:src="${userInfo.nursingImg}" alt=""></p>
					</div>
				</div>
			</div>
		</div>
	<div style="display: none" id="checkInfoSelectOption">
		<option value="">请选择</option>
		<option th:each="list:${checkInfo}" th:value="${list.checkNo}">[[${list.checkName}]]</option>
	</div>
	<script th:src="@{/static/js/jquery-2.1.3.min.js}"></script>
	<script th:src="@{/static/js/nursingImg.js}"></script>
	<script th:src="@{/static/js/basePath.js}"></script>
	<script th:src="@{/static/layui/layui.js}"></script>
		<script>
			var basePath = $("input#basePathInput",parent.document).val();
			var saveFlag = true;

			layui.use([ 'layer',"jquery"], function() {
				let $ = layui.jquery;
				let layer = layui.layer;
				getList($("input#batchNo").val(),layer);

				$("div#addSituation").on("click",function (e) {
					let html = '<div class="new-add-form-con new-add-form-three situation" style="margin-top: 20px"><ul class="overflow border1px border-radius4 pad15px"><li class="width-three"><p><label><em class="red">*</em>情况 ：</label></p><p><select class="form-select">'+$("div#checkInfoSelectOption").html()+'</select></p><h6 class="red cursor deleteHtmlButton"><img src="../static/img/button_delete.png" alt="">删除</h6></li><li class="width-three"><p><label><em class="red">*</em>描述：</label></p><p><textarea placeholder="500字以内" style="resize: none" maxlength="500" rows="3" cols="5" class="layui-textarea resize"></textarea></p></li></ul></div>'
					$(this).before(html);

					$("#dataArticle h6.deleteHtmlButton").unbind().on("click",function (e) {
						$(this).parent().parent().parent().remove();
					})
				})

				$("#dataArticle h6.deleteHtmlButton").unbind().on("click",function (e) {
					$(this).parent().parent().parent().remove();
				})

				$("span#prevButton").on("click",function (e) {
					window.location.href=basePath+"/wardRound/wardRound_two"+"?userNo="+$("#userNo").val()+"&batchNo="+$("input#batchNo").val();
				})

				$("span#nextButton").on("click",function (e) {
					let flag = true;
					let arr = [];
					$("div.situation").each(function (i,v) {
						let type = $("select",$(this)).val();
						let text = $("textarea",$(this)).val();
						if(!isNotNull(type)){
							flag = false;
							layer.msg("请选择情况！");
							return false;
						}else if(!isNotNull(text)){
							flag = false;
							layer.msg("描述不能为空！");
							return false;
						}
						arr.push({"type":type,"text":text});
					})
					if(arr && arr.length > 0) {
						if(arr.length <= 25) {
							if (flag) {
								if (saveFlag) {
									saveFlag = false;
									$.ajax({
										url: "../wardRound/saveLaboratoryRecord",
										type: "post",
										dataType: "json",
										data: {"batchNo": $("input#batchNo").val(), "data": JSON.stringify(arr)},
										success: function (result) {
											saveFlag = true;
											if (result.code == 200) {
												window.location.href = basePath + "/wardRound/wardRound_four?batchNo=" + $("input#batchNo").val() + "&userNo=" + $("input#userNo").val();
											} else {
												layer.msg(result.msg);
											}
										}
									})
								}
							}
						}else{
							layer.msg("情况不能超过25个！");
						}
					}else{
						if(flag) {
							window.location.href = basePath + "/wardRound/wardRound_four?batchNo=" + $("input#batchNo").val() + "&userNo=" + $("input#userNo").val();
						}
					}
				})
			});


			function getList(batchNo,layer) {
				$.ajax({
					url:"../wardRound/getLaboratoryRecord",
					type:"post",
					dataType:"json",
					data:{"batchNo":batchNo},
					success:function (result) {
						if(result.code == 200){
							if(result.data && result.data.length > 0){
								result.data.forEach(function (v,i) {
									let html = '<div class="new-add-form-con new-add-form-three situation" style="margin-top: 20px"><ul class="overflow border1px border-radius4 pad15px"><li class="width-three"><p><label><em class="red">*</em>情况 ：</label></p><p><select class="form-select">' + $("div#checkInfoSelectOption").html() + '</select></p><h6 class="red cursor deleteHtmlButton"><img src="../static/img/button_delete.png" alt="">删除</h6></li><li class="width-three"><p><label><em class="red">*</em>描述：</label></p><p><textarea placeholder="500字以内" style="resize: none" maxlength="500" rows="3" cols="5" class="layui-textarea resize">' + v.text + '</textarea></p></li></ul></div>'
									$("div#addSituation").before(html);

									$("div.situation:last").find("select").val(v.type);
								})

								$("#dataArticle h6.deleteHtmlButton").unbind().on("click",function (e) {
									$(this).parent().parent().parent().remove();
								})
							}
						}else{
							layer.msg(result.msg);
						}
					}
				})
			}

			function isNotNull(val) {
				if(val && $.trim(val) && val != 'undefined' && val != 'null'){
					return true;
				}else{
					return false;
				}
			}
		</script>
	</body>

</html>
